#include "runwithball.h"


string Runwithball:: command(Parser parser)  //will run with the ball towards the goal
{
	//output.str("");

    if (parser.nearertoball==true){
        int kickangle= parser.theirgoal[1];//change this to move the ball to a different place
        int kickpower=20; //changethis to control the power of kicking

    double power=0; 
    if (parser.ball[0]>3 || parser.ball[0]==0)
        power=100; 
    else
        power=30; 

        if(parser.objectball)
        {
            if(parser.ball[1]>5)
                output<<turn(moment*2);

            else if(parser.ball[1]<-5)
                output<<turn(-moment*2);

            else
                if(parser.ball[0]<2)
                    output<<kick(kickpower,kickangle);
                else
                    output<<run(power);
        }
        else
            output<<turn(moment);
    }
    else
        output<<run(0);
		    parser.init(); 

    return output.str();
}

